我在使用回形针时遇到了一些问题。当我有一个跟随大小的“#”(缩放和裁剪)时,我得到422错误。我的日志说明了这一点:
Command :: convert '/tmp/**** (20130110)20130311-13571-xxasmt.png[0]' -auto-orient -resize "150x150#" '/tmp/**** (20130110)20130311-13571-xxasmt20130311-13571-1anrx0y'
[paperclip] An error was received while processing: #<Paperclip::Error: There was an error processing the thumbnail for **** (20130110)20130311-13571-xxasmt>
Completed 422 Unprocessable Entity in 2785ms (Views: 0.8ms | ActiveRecord: 9.1ms)
这是我在模型中的回形针代码:
has_attached_file :image,
:styles => {
:medium => "300x300#",
:thumb => "100x100>",
:standard => "150x150>"
},
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:bucket => "convertkit",
:s3_protocol => "https"
我错过了什么吗?
答案 0 :(得分:0)
public boolean wasRinging = false;@
Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_IN)) {
if ((bundle = intent.getExtras()) != null) {
state = bundle.getString(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
inCall = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
wasRinging = true;
ringing = true;
Date dt = new Date();
int hours = dt.getHours();
int minutes = dt.getMinutes();
int seconds = dt.getSeconds();
String curTime = hours + "" + minutes + "" + seconds;
//Toast.makeText(context," "+curTime,Toast.LENGTH_LONG).show();
int mTime = Integer.parseInt(mrng.toString());
int eTime = Integer.parseInt(evng.toString());
int currentTime = Integer.parseInt(curTime.toString());
if (currentTime < mTime && currentTime > eTime) {
//workinhrs=true;
String work = "no";
Toast.makeText(context, " " + work, Toast.LENGTH_LONG).show();
} else {
String work = "yes";
Toast.makeText(context, " " + work, Toast.LENGTH_LONG).show();
}
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telephonyManager.getSimState();
switch (simState) {
case (TelephonyManager.SIM_STATE_READY):
{
// Get the name of the SIM operator
String simOperatorName = telephonyManager.getSimOperatorName();
//get agent phune number
String lineNumber = telephonyManager.getLine1Number();
// Toast.makeText(context,"name : "+simOperatorName+ "number : " + lineNumber , Toast.LENGTH_SHORT).show();
}
}
String out = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss").format(new Date());
// Toast.makeText(context, "IN : " + inCall+ " : "+ out, Toast.LENGTH_LONG).show();
//ion class call the url Api ang get the values fron the server.
//"http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors" is dummy Link used to check the Application.
/* Ion.with(context)
.load("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
// do stuff with the result or error
Log.i("Tag", "onCompleted" + result);
}
});*/
// Toast.makeText(context, "IN JSON ION URl ", Toast.LENGTH_SHORT).show();
} else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
if (wasRinging == true) {
// calldisconnect=true;
if (ringing) {
if (ringing == true && callrecived == true) {
String RCall = "Recived";
Toast.makeText(context, " " + RCall, Toast.LENGTH_LONG).show();
}
}
Toast.makeText(context, "ANSWERED", Toast.LENGTH_SHORT).show();
start_time = System.currentTimeMillis();
// String out = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss").format(new Date());
File sampleDir = new File(Environment.getExternalStorageDirectory(), "/TestRecordingDasa1");
if (!sampleDir.exists()) {
sampleDir.mkdirs();
}
String file_name = inCall;
try {
audiofile = File.createTempFile(file_name, ".amr", sampleDir);
} catch (IOException e) {
e.printStackTrace();
}
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audiofile.getAbsolutePath());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
recorder.start();
recordstarted = true;
Toast.makeText(context, "Recording Started ", Toast.LENGTH_SHORT).show();
callrecived = true;
/* if(callrecived){
callrecived=true;
Log.d("call rec", "call recived true...................................");}*/
}
} else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
wasRinging = false;
callidle = true;
calldisconnect = false;
if (ringing) {
if (ringing == true && callrecived == true) {
String mCall = "cal ended";
Toast.makeText(context, " " + mCall, Toast.LENGTH_SHORT).show();
} else {
String mCall = "missed call ";
Toast.makeText(context, " " + mCall, Toast.LENGTH_SHORT).show();
}
}
// Toast.makeText(context, "REJECT || DISCO", Toast.LENGTH_SHORT).show();
if (recordstarted) {
recorder.stop();
recordstarted = false;
}
//end_time = System.currentTimeMillis();
long total_time = start_time;
//long second= ((total_time/1000)%60);
long second = ((total_time) / 60000) % 60;
// long seconds = TimeUnit.MILLISECONDS.toSeconds(total_time);
Toast.makeText(context, "Call Duration: " + second, Toast.LENGTH_SHORT).show();
Ion.with(context)
.load("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors")
.asJsonObject()
.setCallback(new FutureCallback < JsonObject > () {@
Override
public void onCompleted(Exception e, JsonObject result) {
// do stuff with the result or error
Log.i("Tag...........", "onCompleted.............." + result);
}
});
// Toast.makeText(context, "IN JSON ION URl Call Rejected ", Toast.LENGTH_SHORT).show();
} else if (state.equals(Call.STATE_DISCONNECTED)) {
wasRinging = true;
// calldisconnect=false;
if (ringing) {
if (ringing == true && callrecived == true && callidle == false) {
String dCall = "call disconnected";
Toast.makeText(context, " " + dCall, Toast.LENGTH_LONG).show();
}
}
}
}
} else if (intent.getAction().equals(ACTION_OUT)) {
if ((bundle = intent.getExtras()) != null) {
outCall = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Toast.makeText(context, "OUT : " + outCall, Toast.LENGTH_SHORT).show();
}
}
}